
const path = require('path');
function imagePlugin(context) {
  const { app } = context;
  app.use(async (ctx, next) => {
    if (ctx.path.endsWith(".png") && ctx.headers.referer
      && ctx.headers.referer.indexOf('.vue') !== -1) {
      ctx.type = 'js';
      ctx.body = `const url = '${ctx.path}';export default url`;
      return;
    }
    return next();
  });
}

module.exports = imagePlugin;